from functools import wraps
from time import time
from common.settings import logger


def timer(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        start_time = time()
        result = func(*args, **kwargs)
        end_time = time()
        logger.info(f'{func.__name__} 执行了：{end_time - start_time:.4f}秒')
        return result

    return wrapper
